1 Data upload

2 ND removed, Converted to a Dataframe

#replace ND with 0

tr <- matrix(data = NA, ncol = ncol(dt[,c(1:44)]), nrow=nrow(dt))
colnames(tr) <- colnames(dt[,c(1:44)])
for (i in 12:44)
{
  tr[,c(i)] <- gsub(".*ND.*", 0, dt[,i])
}

for(i in 1:11)
{
  tr[,c(i)] <- dt[,c(i)]
}
   

#transform to dataframe
tr <- as.data.frame.matrix(tr) #A correct command to change the dataset to dataframe after transformations
tr[,12:44] <- sapply(tr[,12:44],as.numeric) # Change a character to numeric (double)
typeof(tr$Cu_concentration) # confirm the value is no longer a character
## [1] "double"

3 Head of the dataset

head(tr)
##      Scientific_Name Group Plot Sample_Name Tube_No Type_of_Sample Total_Weight
## 1 Allionia incarnata    G3   P1     P1_29_1   30;31           leaf         0.55
## 2 Allionia incarnata    G3   P1       P1_30      28           leaf        0.166
## 3 Allionia incarnata    G3   P1   P1_29_1_2      29           leaf        0.213
## 4 Allionia incarnata    G3   P2      P2_E12   33;34           leaf        0.332
## 5 Allionia incarnata    G3   P2    P2_E12_1      32           leaf        0.183
## 6 Allionia incarnata    G3   P2    P2_E12_2      26           leaf        0.164
##   Cup_No pXRF_measurement_ID               File Material Cl_concentration
## 1     17                2126 Scan2126_19.14.hdx    Plant              580
## 2     18                2127 Scan2127_19.19.hdx    Plant              306
## 3     19                2128 Scan2128_19.25.hdx    Plant              527
## 4     20                2129 Scan2129_19.30.hdx    Plant             2576
## 5     21                2130 Scan2130_19.35.hdx    Plant             4756
## 6     22                2131 Scan2131_19.39.hdx    Plant              753
##   Cl_uncertainty Ca_concentration Ca_uncertainty Ti_concentration
## 1            268            48102            704            143.0
## 2            178            22621            439            132.0
## 3            259            47147            698            124.0
## 4            462            37856            611            146.0
## 5            619            29095            530             90.3
## 6            234             6209            233             30.6
##   Ti_uncertainty Cr_concentration Cr_uncertainty Mn_concentration
## 1           27.5              7.7            5.5             36.2
## 2           22.5              4.8            4.0             47.8
## 3           25.7             10.9            6.2             25.2
## 4           26.3             10.9            6.0             30.7
## 5           20.5             10.6            5.6              0.0
## 6           11.5              0.0            2.5              0.0
##   Mn_uncertainty Fe_concentration Fe_uncertainty Ni_concentration
## 1           10.0             1037           33.0                0
## 2           10.7             1709           46.9                0
## 3            9.1              866           30.8                0
## 4           10.0             1320           35.8                0
## 5            5.8              668           26.6                0
## 6            5.1              371           23.4                0
##   Ni_uncertainty Cu_concentration Cu_uncertainty Zn_concentration
## 1            1.2             37.5            4.5              0.0
## 2            1.2              8.1            3.2             11.8
## 3            1.2             35.9            5.0              0.0
## 4            1.2             47.1            5.1              0.0
## 5            1.2             26.1            4.6              0.0
## 6            1.5              7.9            3.2              0.0
##   Zn_uncertainty As_concentration As_uncertainty Se_concentration
## 1            1.1              5.0            0.3              1.0
## 2            3.8              2.5            1.5              0.0
## 3            1.2              6.5            0.4              0.8
## 4            1.8              6.2            0.4              2.6
## 5            1.5              4.4            1.2              2.7
## 6            1.7              3.3            1.6              3.6
##   Se_uncertainty Cd_concentration Cd_uncertainty Re_concentration
## 1            0.6              0.0            2.5              0.0
## 2            0.6              0.0            4.7              0.0
## 3            0.6              0.0            3.8              0.0
## 4            0.7              0.0            4.5              4.6
## 5            1.0             20.1           20.1              6.4
## 6            1.5              0.0           14.2              0.0
##   Re_uncertainty Hg_concentration Hg_uncertainty Tl_concentration
## 1            1.5                0            0.4                0
## 2            2.1                0            0.6                0
## 3            1.9                0            0.5                0
## 4            2.6                0            0.5                0
## 5            3.4                0            0.7                0
## 6            2.9                0            0.8                0
##   Tl_uncertainty Pb_concentration Pb_uncertainty Substrate_RT
## 1            0.6                0            0.9   0.05758524
## 2            0.7                0            2.5   0.01436361
## 3            0.5                0            1.0   0.03456240
## 4            0.5                0            0.8   0.05420076
## 5            0.9                0            1.9   0.02482426
## 6            1.2                0            2.8   0.01104340

4 Subsets and wrangling

#Filtering with tydeverse library
dt_plants <- filter(tr,  Scientific_Name != 'QA_Sample')

P1 <- filter(dt_plants, Plot == "P1")
P2 <- filter(dt_plants, Plot == "P2")
P5 <- filter(dt_plants, Plot == "P5")
P6 <- filter(dt_plants, Plot == "P6")
P125 <- filter(dt_plants, Plot != "P6")

Se_best <- subset(dt_plants, Scientific_Name == 'Isocoma cf. tenuisecta' | Scientific_Name == 'Populus fremontii' | Scientific_Name == 'Senegalia (Acacia) greggii' )

Re_best <- subset(dt_plants, Scientific_Name == 'Isocoma cf. tenuisecta' | Scientific_Name == 'Baccharis sarothroides' | Scientific_Name == 'Senegalia (Acacia) greggii'| Scientific_Name == 'Nultuma (Prosopis) velutina' | Scientific_Name == 'Mimosa biuncifera (=aculeaticarpa)' | Scientific_Name == 'Fraxinus velutina'| Scientific_Name == 'Datura wrightii' )


# Dropping uncertainty columns for PCA analysis

dt_plants_nounc = select(dt_plants, -Cl_uncertainty,-Ca_uncertainty, -Ti_uncertainty,
                         -Cr_uncertainty, -Mn_uncertainty, -Fe_uncertainty, -Ni_uncertainty, -Cu_uncertainty,
                         -Zn_uncertainty, -As_uncertainty, -Se_uncertainty, -Cd_uncertainty, -Re_uncertainty, -Hg_uncertainty,
                         -Tl_uncertainty, -Pb_uncertainty, -Substrate_RT)

dt_plants_nounc = select(dt_plants_nounc, -Hg_concentration, -Tl_concentration, -Pb_concentration, -Ni_concentration)


#Filtering plants By Plot with subset function

dt_plants_nounc1 <- subset(dt_plants_nounc, Plot=="P1")
dt_plants_nounc2 <- subset(dt_plants_nounc, Plot=="P2")
dt_plants_nounc5 <- subset(dt_plants_nounc, Plot=="P5")
dt_plants_nounc6 <- subset(dt_plants_nounc, Plot=="P6")
dt_plants_nounce15 <- subset(dt_plants_nounc, Plot=="P1" | Plot=="P5")
dt_plants_nounce125 <- subset(dt_plants_nounc, Plot=="P1" | Plot=="P5" | Plot=="P2")

#Removing _concentration from column names

colnames(dt_plants_nounce125)[12] <- "Cl"
colnames(dt_plants_nounce125)[13] <- "Ca"
colnames(dt_plants_nounce125)[14] <- "Ti"
colnames(dt_plants_nounce125)[15] <- "Cr"
colnames(dt_plants_nounce125)[16] <- "Mn"
colnames(dt_plants_nounce125)[17] <- "Fe"
colnames(dt_plants_nounce125)[18] <- "Cu"
colnames(dt_plants_nounce125)[19] <- "Zn"
colnames(dt_plants_nounce125)[20] <- "As"
colnames(dt_plants_nounce125)[21] <- "Se"
colnames(dt_plants_nounce125)[22] <- "Cd"
colnames(dt_plants_nounce125)[23] <- "Re"

colnames(dt_plants_nounc6)[12] <- "Cl"
colnames(dt_plants_nounc6)[13] <- "Ca"
colnames(dt_plants_nounc6)[14] <- "Ti"
colnames(dt_plants_nounc6)[15] <- "Cr"
colnames(dt_plants_nounc6)[16] <- "Mn"
colnames(dt_plants_nounc6)[17] <- "Fe"
colnames(dt_plants_nounc6)[18] <- "Cu"
colnames(dt_plants_nounc6)[19] <- "Zn"
colnames(dt_plants_nounc6)[20] <- "As"
colnames(dt_plants_nounc6)[21] <- "Se"
colnames(dt_plants_nounc6)[22] <- "Cd"
colnames(dt_plants_nounc6)[23] <- "Re"

5 Data Visualization

5.1 Boxplots - Cu - All plots

Cu_AllPlots<- ggplot(dt_plants, aes(x = reorder(Scientific_Name, Cu_concentration, FUN = median), y = Cu_concentration, group=Scientific_Name)) +
  geom_boxplot()+theme_classic()+theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),axis.title.x=element_blank())+
  #theme(legend.position = "none")+
  scale_x_discrete(guide = guide_axis(angle = 0))+
  geom_jitter(aes(colour = Plot), size=1) +
  ylim(0,600)+
  coord_flip()+
  theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))
#scale_fill_manual(values = c("#38A6A5", "#73AF48", "#EDAD08", "#CC503E"))
Cu_AllPlots

5.2 Boxplots - Re - All Plots

Re_AllPlots<- ggplot(dt_plants, aes(x = reorder(Scientific_Name, Re_concentration, FUN = median), y = Re_concentration, group=Scientific_Name)) +
  geom_boxplot()+theme_classic()+theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),axis.title.x=element_blank())+
  #theme(legend.position = "none")+
  scale_x_discrete(guide = guide_axis(angle = 0))+
  geom_jitter(aes(colour = Plot), size=1) +
  #ylim(0,600)+
  coord_flip()+
  theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))
#scale_fill_manual(values = c("#38A6A5", "#73AF48", "#EDAD08", "#CC503E"))
Re_AllPlots

5.3 Boxplots - Re - Selected species

Re_box <- ggplot(Re_best, aes(x = reorder(Scientific_Name, Re_concentration, FUN = median), y = Re_concentration, fill=Scientific_Name)) +
  geom_boxplot()+theme_classic()+theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),axis.title.x=element_blank())+
  theme(legend.position = "none")+
  scale_x_discrete(guide = guide_axis(angle = 45))+
  geom_jitter(color="#85b8bc", size=2, alpha=0.9) +
  theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))+
  #scale_fill_manual(values = c("", "", "", "", "", "","" ))
  scale_fill_manual(values = c("#4b2866", "#c7abdd", "#a578c9", "#381e4c", "#8347b2", "#5d327f","#251433" ))
  #scale_fill_brewer(palette = "Greens")

Re_box

5.4 Boxplots - Zn - All Plots

Zn_AllPlots<- ggplot(dt_plants, aes(x = reorder(Scientific_Name, Zn_concentration, FUN = median), y = Zn_concentration, group=Scientific_Name)) +
  geom_boxplot()+theme_classic()+theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),axis.title.x=element_blank())+
  #theme(legend.position = "none")+
  scale_x_discrete(guide = guide_axis(angle = 0))+
  geom_jitter(aes(colour = Plot), size=1) +
  #ylim(0,600)+
  coord_flip()+
  theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))
#scale_fill_manual(values = c("#38A6A5", "#73AF48", "#EDAD08", "#CC503E"))
Zn_AllPlots

5.5 Boxplots - Se - All Plots

Se_AllPlots<- ggplot(dt_plants, aes(x = reorder(Scientific_Name, Se_concentration, FUN = median), y = Se_concentration, group=Scientific_Name)) +
  geom_boxplot()+theme_classic()+theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),axis.title.x=element_blank())+
  #theme(legend.position = "none")+
  scale_x_discrete(guide = guide_axis(angle = 0))+
  geom_jitter(aes(colour = Plot), size=1) +
  ylim(0,60)+
  coord_flip()+
  theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))
#scale_fill_manual(values = c("#38A6A5", "#73AF48", "#EDAD08", "#CC503E"))
Se_AllPlots

5.6 Boxplots - Se - Selected species

Se_box <- ggplot(Se_best, aes(x = reorder(Scientific_Name, Se_concentration, FUN=median), y = Se_concentration, fill=Scientific_Name)) +
  geom_boxplot()+theme_classic()+theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),axis.title.x=element_blank())+
  theme(legend.position = "none")+
  scale_x_discrete(guide = guide_axis(angle = 45))+
  geom_jitter(color="#85b8bc", size=3, alpha=0.9) +
  theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))+
  scale_fill_manual(values = c("#251433", "#c7abdd", "#8347b2"))
Se_box

5.7 Boxplots - Cu - Plot 6

Plants collected at the plot 6 were growing directly on the mine tailings that were exposed on the area of 100 x 100 m. Shrubs were also collected in the close vicinity to the tailings given their rooting depths.

Plot 6

Cu_Plot6 <- ggplot(P6, aes(x = reorder(Scientific_Name, Cu_concentration, FUN = median), y = Cu_concentration, group=Scientific_Name)) +
  geom_boxplot()+theme_classic()+theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),axis.title.x=element_blank())+
  #theme(legend.position = "none")+
  scale_x_discrete(guide = guide_axis(angle = 0))+
  geom_jitter(aes(colour = Plot), size=1.6) +
  ylim(0,600)+
  coord_flip()+
  theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))
  #scale_fill_manual(values = c("#38A6A5", "#73AF48", "#EDAD08", "#CC503E", "#38A6A5", "#73AF48", "#EDAD08", "#CC503E", "#38A6A5", "#73AF48", "#EDAD08"))
Cu_Plot6